<template>
    <div>
        <h1>登录</h1>
        <table class="table table-bordered">
            <tr>
                <td align="right">账号</td>
                <td><input type="text" v-model="info.userName"></td>
            </tr>
            <tr>
                <td align="right">密码</td>
                <td><input type="password" v-model="info.userPwd"></td>
            </tr>
            <tr>
                <td></td>
                <td><input type="button" value="登录" class="btn btn-success" @click="login"></td>
            </tr>
        </table>
    </div>
</template>

<script setup lang="ts">
import{ref,reactive}from 'vue'
import axios from 'axios'
import router from '@/router';
let info =ref({
    userName:'',
    userPwd:''
})

const login=()=>{
   if(info.value.userName==''){
    alert('账号不为空');
    return;
   }
   if(info.value.userPwd==''){
    alert('密码不为空');
    return;
   }
   axios({
    url:'/api/Base/Login',
    method:'post',//请求方式
    params:info.value  //params  根据后端而定   
   })
   .then((res)=>{
       console.log(res);
       if(res.data==-1){
        alert('账号不存在');
        return;
       }
       if(res.data==-2){
        alert('密码错误');
        return;
       }
       alert('登录成功');
       router.push('/memberAdd');
   })
   .catch((err)=>{
        console.log(err);
   })

}
</script>

<style scoped>

</style>